using UnityEngine;
using System.Collections;

public class InputManager : MonoBehaviour 
{
	GUIText m_guiDebug = null;
	
	void Awake () 
	{
		Input.multiTouchEnabled = true;
	}
	
	// Use this for initialization
	void Start()
	{
		GameObject objGuiDebug = GameObject.Find("GUI Debug");
		m_guiDebug = objGuiDebug.GetComponent<GUIText>();
		m_guiDebug.text = "Touch To Screen!!";
	}
	
	// Update is called once per frame
	void Update () 
	{
		string debugTouch = string.Empty;
		
		foreach (Touch _touch in Input.touches)
		{
			Vector3 touchWorldPos = Camera.main.ScreenToWorldPoint(new Vector3(_touch.position.x, _touch.position.y, Camera.main.nearClipPlane));
			debugTouch += _touch.fingerId + ". " + _touch.position + " -> " + touchWorldPos + "\n";
		}
		
		if (Input.touchCount == 0 && Input.GetMouseButton(0))
		{
			Vector3 mouseWorldPos = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, Camera.main.nearClipPlane));
			debugTouch += "MouseButton(0) down : " + Input.mousePosition + " -> " + mouseWorldPos + "\n";
		}
		
		if (debugTouch != string.Empty)
		{
			m_guiDebug.text = debugTouch;
		}
	}
}
